package com.itheima.springbootwebtlias.commons;


import com.itheima.springbootwebtlias.exception.BaseException;
import com.itheima.springbootwebtlias.exception.DeletionIsNotAllowed;
import com.itheima.springbootwebtlias.pojo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public Result defaultExceptionionHanddler(Exception e) {
        e.printStackTrace();
        log.error("记录异常信息：" + e.getMessage());


        log.info("叫人帮忙");

        return Result.error("网络异常... ...");
    }


    @ExceptionHandler(BaseException.class)
    public Result defaultcommosmHanddler(BaseException e) {

        log.error("记录异常信息：" + e.getMessage());

        return Result.error(e.getMessage());
    }


}
